﻿using NUnit.Framework;
using RenewalProjects.Libraries.Wcf.EasyProxy.ChannelAllocators.Settings;
using System;

namespace RenewalProjects.Libraries.Wcf.EasyProxy.Tests.Fixtures
{
	[TestFixture]
	public class PooledChannelAllocatorSettingsFixture
	{
	    #region Test Methods
	    
		[Test]
		public void PooledChannelAllocatorSettings_validate_on_default_values()
		{
			PoolChannelAllocatorSettings settings = new PoolChannelAllocatorSettings();
			settings.ValidateProperties();
		}

		[ExpectedException(typeof(InvalidOperationException))]
		[Test]
		public void PooledChannelAllocatorSettings_validate_with_ReadyChannelMax_negative()
		{
			PoolChannelAllocatorSettings settings = new PoolChannelAllocatorSettings
			{
				ReadyChannelMax = -1
			};
			settings.ValidateProperties();
		}

		[ExpectedException(typeof(InvalidOperationException))]
		[Test]
		public void PooledChannelAllocatorSettings_validate_with_StandbyChannelMax_negative()
		{
			PoolChannelAllocatorSettings settings = new PoolChannelAllocatorSettings
			{
				StandbyChannelMax = -1
			};
			settings.ValidateProperties();
		}

		[ExpectedException(typeof(InvalidOperationException))]
		[Test]
		public void PooledChannelAllocatorSettings_validate_with_StandbyChannelMax_and_ReadyChannelMax_as_0()
		{
			PoolChannelAllocatorSettings settings = new PoolChannelAllocatorSettings
			{
				StandbyChannelMax = 0,
				ReadyChannelMax = 0
			};
			settings.ValidateProperties();
		}

		[ExpectedException(typeof(InvalidOperationException))]
		[Test]
		public void PooledChannelAllocatorSettings_validate_with_MaxChannelOpenTime_negative()
		{
			PoolChannelAllocatorSettings settings = new PoolChannelAllocatorSettings
			{
				MaxChannelOpenTime = new Nullable<TimeSpan>(new TimeSpan(0, 0, 0, 0, -1))
			};
			settings.ValidateProperties();
		}
		
		#endregion
	}
}